# Contributor: Iztok Fister, Jr. <iztok@iztok-jr-fister.eu>
# Maintainer: Iztok Fister, Jr. <iztok@iztok-jr-fister.eu>
pkgname=py3-statsmodels
pkgver=0.14.4
pkgrel=0
pkgdesc="Statistical modeling and econometrics in Python"
url="https://www.statsmodels.org/"
arch="all"
license="BSD-3-Clause"
depends="
	py3-numpy
	py3-packaging
	py3-pandas
	py3-patsy
	py3-scipy
	python3
	"
makedepends="
	cython
	py3-numpy-dev
	py3-setuptools_scm
	python3-dev
	"
checkdepends="py3-pytest-xdist py3-pytest-cov py3-joblib py3-matplotlib"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://files.pythonhosted.org/packages/source/s/statsmodels/statsmodels-$pkgver.tar.gz"
builddir="$srcdir/statsmodels-$pkgver"
# weird failures
options="!check"

build() {
	# LTO metadata is included in some libraries, which causes linking problems.
	export CFLAGS="$CFLAGS -fno-lto"

	# Force rebuilding of cython sources.
	find . -name *.c -delete

	python3 setup.py build
}

check() {
	local jobs="$((${JOBS:-4} / 2))"
	PYTHONPATH="$(echo build/lib*)" python3 -P -c "import statsmodels; statsmodels.test(['-n $jobs'], exit=True)"
}

package() {
	python3 setup.py install --skip-build --root="$pkgdir"

	find "$pkgdir"/usr/lib/python3.*/site-packages/statsmodels -type d -name "tests" -exec rm -rf {} \+

	rm -rf "$pkgdir"/usr/lib/python3.*/site-packages/statsmodels/.pytest_cache/
}

sha512sums="
db3bd19b8b47af453ad6fbd24449a621895e4237bbc8b7813810306748c32a3fbf005387a0e1e8db550c9c4a59666bdd50aeb49e24f0ecb86619bc90f166f5f9  py3-statsmodels-0.14.4.tar.gz
"
